package com.learn;

import java.awt.Font;
import java.sql.SQLException;
import java.util.List;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class SearchAllWindow extends JPanel {
	private JTable table;
	private DBConnection dbc;
	private List<String[]> students;
	private String[] header = {"学号：","姓名：","班级：","社团：","社团：","职位："};
	private String[][] rows;
	/**
	 * Create the panel.
	 * 
	 * @throws SQLException
	 */
	public SearchAllWindow() throws SQLException {
		Font labelFont = new Font("宋体", Font.PLAIN, 13); // 标签字体
		setLayout(null);
		dbc = new DBConnection();
		queryall();
		table = new JTable(rows, header);
		table.setBounds(0, 0, 800, 500);
		table.setFont(labelFont);
		JScrollPane jsp=new JScrollPane(table);
		jsp.setBounds(0, 0, 800, 500);
		add(jsp);
	}

	private void queryall() throws SQLException {
		students = dbc.queryAllInfo();
		rows = new String[students.size()][6];
		students.toArray(rows);
	}
}
